package com.dcshop.demo.controller;

import com.github.ontio.OntSdk;
import com.github.ontio.account.Account;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;

import java.util.Map;

public class SignController extends AbsController {

    /**
     * 专家对产品签名
     *
     * @param reqMap
     * @return
     */
    @PostMapping("/signProduct")
    public Boolean signProduct(@RequestBody Map<String, Object> reqMap) {

        String productid = reqMap.get("productid").toString();

        if (StringUtils.isEmpty(productid)) {
            return false;
        }

        OntSdk ontSdk = null;

        try {
            ontSdk = getOntSdk();

            //TODO 专家对产品签名


            Account payAccount = getPlatformAccount(ontSdk);

            //TODO 客户在登陆系统的时候会取到productOwerAccount，测试先用payAccount
            Account productOwerAccount = payAccount;


            //否满足多位签名条件，注册数据到链上，调用资产评估证明 智能合约
            //TODO 发送 上链消息


            return true;


        } catch (Exception e) {
            System.out.println(e.getMessage());
            return false;
        }

    }


}
